import java.util.Random;
import java.util.Scanner;

public class Number {
    public static void main(String[] args) {
        Random random = new Random();
        int targetNumber = random.nextInt(100) + 1; // 生成1到100之间的随机数
        Scanner scanner = new Scanner(System.in);
        int guess;

        System.out.println("欢迎来到猜数字游戏！我已经想好了一个1到100之间的数字。");

        while (true) {
            System.out.print("请输入你的猜测：");
            guess = scanner.nextInt();

            if (guess > targetNumber) {
                System.out.println("抱歉，你猜大了！");
            } else if (guess < targetNumber) {
                System.out.println("抱歉，你猜小了！");
            } else {
                System.out.println("恭喜你，猜对了！");
                break; // 猜对后退出循环
            }
        }

        scanner.close();
        System.out.println("游戏结束，谢谢参与！");
    }
}